package javanio.channel;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.InetSocketAddress;
import java.nio.channels.DatagramChannel;
import java.nio.channels.FileChannel;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

/**
 * Created by IntelliJ IDEA.
 * User: liuliwei
 * Date: 2017-09-19
 * Time: 下午7:53
 * Description: ${description}
 * fileIO/streamIO
 * file:FileChannel
 * socket:SocketChannel ServerSocketChannel DatagramChannel
 */
public class ChannelTest {
    public static void main(String[] args) throws IOException {
        int someport=3;
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress("somehost", someport));

        ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
        serverSocketChannel.bind(new InetSocketAddress(someport));

        DatagramChannel datagramChannel = DatagramChannel.open();

        RandomAccessFile randomAccessFile = new RandomAccessFile("somefile", "r");
        FileChannel fileChannel = randomAccessFile.getChannel();
    }
}
